// todo 创建路由  配置路由规则  导出路由实例对象
//线引入vue模块,不然无法注册vue

import Vue from 'vue'

//引入路由模块
import VueRouter from 'vue-router'

// 导入页面
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Search from '@/views/Search'
import Play from '@/views/Play'

Vue.use(VueRouter)


//配置路由信息

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },

  {
    path: '/layout',
    component: Layout,
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        component: Home,
        meta: {
          title: '首页'
        }
      },
      {
        path: 'search',
        component: Search,
        meta: {
          title: '搜索'
        }
      }
    ]
  },
  {
    path: '/play',
    component: Play
  }
]


//new vueRouter实例对象

const router = new VueRouter({
  routes
})

//默认导出
export default router